package com.felix.clazz;

/**
 * StaticField
 *
 * @author xjh
 * @version 1.0
 * @date 2019-03-05
 */
public class StaticField {
    private static int count = 100;

    public static int sum = 10;

    static {
        System.out.println("staticSync code");
    }

    {
        System.out.println("code");
    }

    public void method() {
        System.out.println("method");
    }

    public static void method1() {
        System.out.println("staticSync method1");
    }

    public static void main(String[] args) {
        StaticField staticField1 = new StaticField();
        staticField1.count++;
        StaticField staticField2 = new StaticField();
        staticField2.count++;
        StaticField.count--;
        System.out.println(count);
        // 访问静态方法没问题，非静态方法报npe
        ((StaticField) null).method1();
    }
}
